refactor, dont use keyword this so much. borrow scoping ideas from coffeescript