added some code to transfer buffers