The effects of an act upon the agent will be widely different, according to his state of mind at the moment. If you see a child drowning and save it as the result of a direct impulse to bring help, you will emerge none the worse morally. If, on the other hand, you say to yourself, 'It is the part of virtue to succour the helpless, and I wish to be a virtuous man, therefore I must save this child', you will be an even worse man afterwards than you were before.
Source: The Conquest of Happiness, 1930
More info.:
https://russell-j.com/beginner/HA28-030.HTM