commit 2 : rewritten compare function