solve refractored