refactor putChar