refactoring and js-> coffee