increased the buffer size to 4096 and fallback to old method when the buffer size is not large enough, instead of throwing