moved event handlers out of the main app