homolog gathering algorithm