added getopt part