improved the printing functionality