more flexible exception handling