Containment algorithm; currently buggy.