improved string cleaning