working buffer refactor