improved exception handle