Added some error handling... to be continued