fixed bug in buffer