Added repeat function, fixed repeat function