refractored so that reading each file is a separate method