segmentation bug fixed