fix segmentation fault exception