extracted display of output into a separate function