Fix the repeat function