change catching exception to catching IOException