It is the thoughts and memories of the being at the moment of leaving the body that determine its future condition.
Whoever, upon passing away, at the very moment of leaving their body, remembers me alone and immediately reaches my abode, have no doubt, for it is the thoughts and memories of the being at the moment of leaving their body that determine their future condition. Thus, in me, Krishna, in my personal form, always absorbs your thoughts without fail. Dedicating your actions to me, turning your mind and intelligence towards me, you will undoubtedly come to me. At the moment of death, the soul takes a new body, as naturally as it passed, in the previous body, from childhood to youth, then to old age. This change does not trouble those who are aware of their spiritual nature (the awareness of being a spiritual soul, and not the material body with which we wrongly identify). Wherever one's thoughts may be at the time of death, one will unfailingly reach that destination in one's next life. Thus, donning a new material body, the individual spiritual being is granted a specific sense of hearing, sight, touch, taste, and smell, which revolve around the mind. Thus, one enjoys a particular range of sense objects. He who dies in ignorance (of the data relating to God, his true spiritual identity, existential and absolute truth, and true spiritual knowledge) will be reborn in the animal kingdom. Fools cannot understand how a being leaves his body, nor can they determine what kind of body they must assume under the spell of the gunas (the three attributes and modes of influence of material nature: virtue, passion, ignorance). But those whose eyes have been opened by knowledge can be aware of all truths. If someone offers me with love and devotion a leaf, a flower, a fruit, or water, I will accept that offering. Always fill your mind with me and become my complete devotee, constantly dedicate your worship to me, and simply surrender to me. This is the only way to enter my kingdom. I reveal to you here the most secret of knowledge. How can one love God, how can one become His devotee?
I respond to the worship of the pious believer according to the particular transcendental feeling that animates them. Such is My nature. The devotional service offered to Me by living beings rekindles eternal life within them. People freed from these dualities (good-evil, hot-cold, victory-defeat, just-unjust, true-false, etc.) that are the fruits of illusion, people who, in their past lives as in this life, were virtuous, people in whom sin has ceased—they serve Me with determination.