refactor event handlers to reduce code by 50%