fixed Compare function