Changed structure of functions
Abstracted the exception handling for url opening