Fixed remainder for repeats bug