refining logic