refactor movesort