added optparse so it can be ran from the command line