refactored, added test for comparator