Better word counting function.