#6 improve the try and catch block