Fix repeat function