refactoring linked list according to the ADT