code refractoring, nested model