refractoring some code again