refactoring main.coffee