Some algorythm fix