Added logic to avoid saving empty rows