actually split out the main function into it's own module