fixed possible resource leak