fixed unclosed resource in handlers