add data to the list and print the data from prev