added better sanity checking for command line arguments