refactored location endpoint to return a json response