works correctly with duplicated moves