reorganize CoffeeScript code a bit