tidy up option parsing