Cube elimination algorithm