The reward of deeds depends on the intentions
‘Umar ibn al-Khattāb (may Allah be pleased with him) reported that the Prophet (may Allah's peace and blessings be upon him) said: "Verily, the reward of deeds depends on the intentions, and each person will be rewarded according to what he intended. [Al-Bukhari and Muslim].