One verse

Srimad Bhagavatam 10.1.42

10.1.42

यतो यतो धावति दैवचोदितंमनो विकारात्मकमाप पञ्चसु । गुणेषु मायारचितेषु देह्यसौप्रपद्यमान: सह तेन जायते ॥ ४२ ॥

yato yato dhāvati daiva-coditaṁ mano vikārātmakam āpa pañcasu guṇeṣu māyā-raciteṣu dehy asau prapadyamānaḥ saha tena jāyate

yataḥ yataḥ
from one place to another or from one position to another
dhāvati
speculates
daiva-coditam
impelled by accident or deliberation
manaḥ
the mind
vikāra-ātmakam
changing from one type of thinking, feeling and willing to another
āpa
at the end, he obtains (a mentality)
pañcasu
at the time of death (when the material body turns totally into matter)
guṇeṣu
(the mind, not being liberated, becomes attached) to the material qualities
māyā-raciteṣu
where the material energy creates a similar body
dehī
the spirit soul who accepts such a body
asau
he
prapadyamānaḥ
being surrendered (to such a condition)
saha
with
tena
a similar body
jāyate
takes birth

At the time of death, according to the thinking, feeling and willing of the mind, which is involved in fruitive activities, one receives a particular body. In other words, the body develops according to the activities of the mind. Changes of body are due to the flickering of the mind, for otherwise the soul could remain in its original, spiritual body.