Added some exception processing