first attempt at getMaxMatching