Fixed segmentation fault