Centralizing code to fetch url