Changed how to deal the temporary buffer.