more robust URL generation