extract output logic into another method