CSNIRP lab#4: fix buffering issue