added getopt functionality