another linkedlist solution