Refactored using uniq method and general slimming down.