remove buffer, make it thread-safe