added compare function (which can really be replaced by 1 line of matlab,cool)