implement get location function

TODO : optimize the strategy of getting location