Refactor url fetching