Trying to correct the Segmentation fault