Fixing Segmentation Fault Bug