updated totalRecords with the on error