refactoring total token count loop

rewritting loop

adding qc non-sense