converted all manual resource.close to try-with-resource