Modified the location algorithm