updated source code into coffee-script, for better readability