Decreased the complexity level of LinkedList traversal in logic()