fixed all bugs, G matrix is now created