fixed the problem where nearest locations was wrong