fixed printout function