Segmentation fault bug fixed