update the moving function