modified a bit how mass repeat detection works