refactor stream input method, create separate API