New function to apply function on partial buffers