added exceptions to treat code