migrated messageHandler to CoffeScript