refining function