counting ewrror corrected such that multiple repeats do work correctly