The step-wise process of refining the mind is comparable to refining gold - removing the grossest impurities first, then progressively more subtle impurities, until only pure gold remains.
"... in the case of a practitioner devoted to practice, there may be such gross impurities as unskillful conduct in deeds, words, and thoughts. Such conduct the follower of the way gives up, puts away, lets go, and relinquishes.
When one has abandoned these there may still remain such impurities of a moderate degree as lustful, angry, and violent thoughts. Such thoughts the follower of the way gives up, puts away, lets go, and relinquishes.
When one has abandoned these, there may still remain grasping to special states of meditation.
Thus concentration is not yet properly calm or refined; it has not attained to full tranquillity, nor has it achieved mental unification. But there comes a time when the practitioner's mind gains firmness within, settles down, becomes unified and concentrated. With such a concentration the practitioner is able to direct the mind to states of higher insight.
Having completed this initial purification, a follower of the way devoted to practice should from time to time direct attention to three qualities of mind ... concentration, energetic effort, and equanimity. If one gives regular attention to these, then one's mind will become pliant, workable, lucid, and not unwieldy, and it will be well concentrated upon overcoming all fetters and attachments."
adapted from the Anguttara Nikaya, translated by Nyanaponika Thera
Kornfield, Gil Fronsdal eds. “Teachings of the Buddha.” Shambhala, Boston, 2007.