Refactored js map stuff