Do things for the sake of Allah only.
In the battle of Khandaq, the Muslims dug a ditch around themselves for their defence, so that the enemy could not get across.
A man from the enemy side called Amr bin Abdawud who was known for his strength, courage and art of fighting managed to get across the ditch.
All the Muslims were terrified to fight him and only Imam Ali (A) came forward to fight this man.
There was a fierce fight until at last Imam Ali (A) threw Amr down onto the ground and mounted his chest ready to kill him.
Just as Imam Ali (A) was about to kill this enemy of Islam, he spat on the face of our Imam (A).
Everybody was certain that because of this insult, Amr would meet his death even faster still, but to their amazement, Imam Ali (A) moved from Amr’s chest and walked away.
Amr attacked Imam (A) again and after a short while, Imam (A) again overpowered Amr and killed him.
After the battle was over people asked Imam Ali (A) the reason why he had spared Amr’s life when he had first overpowered him.
To which Imam (A) replied that if he had killed him then it would have not been only for the sake of Allah but also for the satisfaction of his anger and so he let him free.
Then Imam (A) controlled his anger and killed Amr purely for the sake of Allah.
Although your intention may be pure to begin with it can very easily change so always make sure you do things for the sake of Allah only.