cleaned up comparator logic, removed unused code, cleaned up a bit