null check implemented in the compare method.