broken Pantelis code into separate functions for easier integration with word clouds.