fix segmentfault error