refactor of main.js and weather.js