trying to fix segmentation fault