Corrected unhandled exceptions

code realted to #1