moved code to coffee script for niceness