Refractored to smaller methods