fixing gp function