adding better implementation of linked list