Using a comparator with variable reference