Refactored work with buffers