modified the js code to use the on method in place of the live one