refactored map display code