Added error handling, and command line params