despite his mechanistic outlook , however , descartes accepted the traditional religious doctrine of the immortality of the soul and maintained that mind and body are two distinct substances , thus exempting mind from the mechanistic laws of nature and providing for freedom of the will .