refining code