Slight if reordering to make error branch last.