main.coffee refactoring