integrate distance and score calculations