Added command line arguments and modularized main code.