fix seg fault issue