Add logic for repeat function