updated the code to print out according to assignment