Changed location helper code to be called within a handler, so that location can be retrieved properly