corrected loop to check integrity