added the delete function. still problems with the last element in the list not appearing