Optimized switch and returned early from errors makes recovery faster