fixed seg fault issue