refactor bufio