refractoring functions