more work on the closest point function