reorder; functions should come before events
missing comments