Properly check for an out of range row index