Fixed bug to correctly repeat based on mode