bug in printing function