there is an error with g(i+1)