refactored code for clarity
protocol agnostic url