First version of exception handling