refactor extract printing report function