The rewards of deeds depends on the intention

Reading Sahih Al-Bukhari, The Book of Revelation