Add setter and getter for totalWords variable