learning_switch3.sh: new algorythm