major refactor event handlers