Improved total words calculation