Coffeescript refactor