Imam al-Shafi'i (may Allah have mercy on him) says that the Messenger of Allah (peace and blessings be upon him) said: "Whoever swears an oath to do something and then considers another thing better than it, let him do the better thing and pay the expiation for his oath."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الجزية / 18853