added exceptions handling