optimized pathsanitise