added getopt
fixed error printouts