refacored version with of singly linked list with ops to get head, list size, get list elements and add at beginning and end