added original flex stream code