Moving algorythm