Fixing null pointer exception in the comparator code.