changed stack to linked lists