moved getlocation function out a bit