Refactored main.js file because I want to load map asynchronously