criticalPlanes code