Refractored code and made resource changes