N_i and N_j optimization