solve the segmentation fault