Changed linked list to stack