fixed potential resource leak