Initialization problem

I wrote STAN code and got initialization error. I think this is because my code might have some errors. Can someone find them?

data {
int<lower = 0> N; //total observations

//num of fixed effects
int<lower = 0> Nx; //mean model
int<lower = 0> Ng; //var model

//num of random effects
int<lower = 0> Nz; //both mean and var model

real y[N]; //observed data

//design matrices for fixed effects
matrix[N, Nx] x; //mean model
matrix[N, Ng] g; //var model

//design matrices for random effects
matrix<lower = 0, upper = 1>[N, Nz] z;
parameters {
//mean model
vector[Nx] beta; //fixed effects
vector[Nz] u; //random effects
real<lower = 0, upper = pow(10, 10)> tauMu; //sd of random effects
transformed parameters {
vector[N] mu;
vector<lower = 0>[N] invSigmaSq;
vector<lower = 0>[N] sigma;

//mean model
mu = multiply(x, beta) + multiply(z, u);
//var model
for (i in 1:N) {
sigma[i] = 1/sqrt(invSigmaSq[i]);
model {
for (i in 1:N) {
y[i] ~ normal(mu[i], sigma[i]);

//priors for mean model
beta ~ normal(0, 10000); //fixed effects
u ~ normal(0, tauMu); //random effects
tauMu ~ uniform(0, pow(10, 10));

//prior for sigma
invSigmaSq ~ gamma(0.5, 0.5);

invSigmaSq is used without being defined. Perhaps you meant to declare it in the parameters block instead of the transformed parameters block.

I fixed it. Thanks!