rewrite, using getopt instaed of asking questions