Optimized error handline code