fixed the bugs in printing functions