Moves URL parsing into helper function