Add exception handling feature

revert this refactoring