better plan intersection algorithm