added some useful string manipulation regarding repeats