This line is definitely wrong (look at the dimensions of gg).