code prints data correctly