-- added callback functions for data and end event