fix buffering bug