updated to use createMemoryBuffer()