main is now exactly functional