Delay between actions 0 causing issues with looping code

I have some code that runs a while loop to check each page of a result set. The code runs fine when the project setting "Delay between actions (in seconds) is set to 1 . If I set the delay to 0 the test produces different results and ends up failing. I will post the sample script hopefully someone can tell me what I am doing wrong. Or is this a bug.

def paginationAttributeValue = ‘’

def totalRows = 0

def pageRowCount = 0

def locatedItems = 0

def pageIndex = 1

paginationAttributeValue = WebUI.getAttribute(findTestObject(‘Common Objects/Pagination/PaginationObject’), ‘md-total’)

totalRows = Integer.parseInt(paginationAttributeValue)

while (totalRows > 0) {
pageRowCount = CustomKeywords.‘supplyflex.SupplyFlexHelpers.getSupplyFlexTableRowCount’(findTestObject(‘Admin/Packaging Hubs Page/Hub Results Table’))

WebUI.comment(WebUI.concatenate('Page Row Count ', pageRowCount.toString()))

locatedItems = CustomKeywords.'supplyflex.SupplyFlexHelpers.countElements'(findTestObject('Admin/Packaging Hubs Page/Language Objects/Languagues/English'))

WebUI.comment(WebUI.concatenate('Located Items ', locatedItems.toString()))

WebUI.verifyEqual(pageRowCount, locatedItems)

WebUI.takeScreenshot(WebUI.concatenate('c:/ScreenShots/FilterLanuage_Post', pageIndex.toString(), '.png'))

CustomKeywords.'supplyflex.SupplyFlexHelpers.supplyflexClick'(findTestObject('Common Objects/Pagination/Next'), 0)

WebUI.comment(WebUI.concatenate('Total rows before ', totalRows.toString()))

totalRows = (totalRows - pageRowCount)

WebUI.comment(WebUI.concatenate('Total rows after ', totalRows.toString()))

pageIndex = (pageIndex + 1)