refactor command_filter