segmentation fault bug fix