printing logic