fixed logic on selecting error codes