2. refactored main.js
 Merged changes in  main.js