resource leak fix