The Reward Of Deeds Depends Upon The Intention.

"The reward of deeds depends upon the intentions and every person will get the reward according to what he has intended. So whoever emigrates to Allah and His Messenger, then his emigration is to Allaah and His Messenger. And whoever emigrates for worldly benefits or for a woman to marry, his emigration was for what he emigrated for." [Saheeh Al-Bukhari]