convert from coffee to plain javascript