Fix bug in buffer