simplified some of the code for building buffers