implement handle_events()