implemented exceptions handling