Refactor command line tool