adding G matrix to calculations