finished implementation of heuristics for choice of origin