shifted function defs to the top, contents below main