Fixed bug in handeling exception