fixed logic for 5.0.4