cleanup event handler functions
cleanup
fix error handling