Might be cleaner to move this into the loop condition.