refactored streams / close
refactoring and move stream close to finally
refactoring and move stream close to finally block