simplifying error logic