wrapped regex substitution in an str call to eliminate unicode and added debug logging