fixed free() bug