fix a memory leak
add more logs