fixed pairs iteration bug