working version of bruteforcePD except with recursive tabulate pairs thing