add free() to fix the memory leackage problem