some code refractoring