added Q for recusrsive segmentation