Fix potential pb
Fix memory leak
close handle to fix memory leak