optimize move, fix write