refactored main.coffee