refactor magic tool
refactor command, add tolerance for replacement