cleanPath method performance improvement