fixed repeat bug, still need to add tests.