added processmaxpairs