rewriting js code using jquery boilerplate