add functions for event handling