Fix the moving algorithm