refactor build pairs