Fix underflow bug in delegate loop