Refactor to use jQuery event model