improved streaming sample