printing history with a function