Minimum Imbalance code