fix function_events script