refactor command execution