added function to delete the last node.