Refining code