Re-did the try-with-resources which I changed in last commit