Fixed segmentation error