bug fix: close streams