trying optimization for int dist