fixed the segmentation fault problem