slightly more efficient word counting