Refactoring...
Refactored main.js