Moved the local url variable inside the if block