removed the plane constraint on the function to make it more general