improved next location algorithm