improved stream code to listen for data events instead of readable events