Corrected logical error:: free before usage