Code refactoring on map rendering