first fix segmentation fault
Fixed segmentation fault