Refactor output buffer
Added input