Added check for empty rows