Add function for events