using a shared buffer to avoid copying between vectors