Refactored comparator into its own class file