added conditional logic around search total line to prevent nil object error