improved url parsing