refactor command line option parsing