refactor for single-line mode