repeat periods algorithm update