Moved command line argument handling out of main function