replaced the quadric intersection code