added exepction handling