fixed segmentation error