Fixed segmentation fault problem