move event handling into dom