partly complete the code for location