Move up the locate calculation save processing time.
Merge pull request #995 from ESwordTheCat/riW3nfAj

Move up the locate calculation to save processing time.