Added the buffer to the on_data callback