local variable 'url' referenced before assignment