1. replace buffer with streambuf