refactor code to have quick query of location