refactor command line parsing