added exeption handling