Missing context for the .on() method. Also remove dead code.
jQuery optimisation