refactor: try-with-resources (AutoClosable)