segmentfault bug fix