Merged several events to remove duplicate code