refeactored API, using streaming API convention