Refractoring code