Added some basic error handing