Fix detection whether errors occured or not