added function to find nearest gridpoint