refactored location controller