refactor command interpreter