separate function for buffer data handling