updated totalRecords with the on error callback