use getopts - the argument handling code is horrible
