fix a potential resource leak