Intention is most important factor for getting Reward from an action, Same action may have different Result Innamal Aamal o Binniyat

On the authority of ameer ul -mumineen (the commander of the faithful), abu hafs Umar ibn al-Khattab (may Allah be pleased with him), who said: (Related in Bukhari and Muslim)

I heard the Messenger of Allah (peace and blessings of Allah be upon him) say,
 “Actions are but by intentions and every man shall have only that which he intended. Thus he whose migration (hijrah from Makkah to Madina) was for Allah and His Messenger, his migration was for Allah and His Messenger, and he whose migration was to achieve some worldly benefit or to take some woman in marriage, his migration was for that for which he migrated.”

It is related by the two imams of the scholars of hadeeth, Abu Abdullah Muhammad ibn Ismael
ibn Ibraheem ibn al-Mugheera ibn Bardizbah al-Bukhari and Abu-l-Husain Muslim ibn al-Hajjaj
ibn Muslim al-Qushairee an-Naisaboree, in their two Saheehs, which are the soundest of compiled