move main function to its own file. Parse command line arguments with optpare