refactored code. need to fix the popup title on the map