made the buffer thread safe