fix segmentation fault error