refactored main.js into modules