New algorithm for mymode mode