Fix #4 refactor main.js