fixed outermost error handling