add extractToBuffers function