Simplified logic by removing the list concept.