finish refactor, change repeat function to event delegation