changed code for better use of the coffescript scope functionality