Refactor command arg filtering