Added ordered unique list function and refactored the code to use HashSet.