fix segmentfault bug