using optparse rather than hand-rolled solution