adds command line functionality.  Needs optimization!