refactored code for new map render