Added some error-handling