missed one
refactored reading of rows from two identical loops into a function