Improved nested comparator