add repeat function and debugging