fix segmentation falt issues