fix the wasted buffer open/close