Small change to fix seg fault and mem leak