updated word counting code