moved the bad charsets to an array. moved the string search duplicated code to a function.