fixed segmentation fault