changed 'row' reference to 'i'