fix the resource leak