added logic to addFirst and AddLast methods