Added error checking with comparator