top function  completed in stack with linked list