Fixed segmentation issue