Adding the fix for segmentation error