fixed invalid move bug
merge max's bugfix