Handle url being nil or empty
Refactor