move event handlers out of DOM build code