modified to take command line arguments