algorythm modified