move creation of the dictionary into distance