now uses optparse instead of getopt