refine location algorithm