fixed bug upon closure