some refactor for output