fixed error in exception handling