Changed location from a global variable

Got rid of global references and passed the location variable between
methods