Changed function locate by hunt. It is more efficient.