movement algorithm bug fix