in process of fixing dangling pointer issue