Fixed bug with buffering