moved locations creation into getLocations() function.