added better exception writing