Changed compare function - added dictionary and lambda