handles exception