Refactored some location code as per feedback