corrected compare method