use try-with-resources