fix incorrect row indexing