added function for counting nodes in the list