used getopt to parse arguments.