fix buffer read