Added some exception handling