fix bug in compare (Thanks Lincoln)