added getopt, and some try blocks