improved url cleaning algorithm