If you swear an oath then see something better, do the better and expiate the oath. The Prophet ﷺ said: “By Allah, I do not swear an oath and then see something better than it, but I do the better and expiate my oath.” (al-Bukhārī). Expiation: feed or clothe ten poor people, or free a slave; if unable, fast three days (al‑Māʾidah 5:89).
العربية: عن أبي موسى الأشعري رضي الله عنه أنّ النبيّ ﷺ قال: «والله لا أحلِف على يمينٍ فأرى غيرها خيرًا منها إلا كفّرتُ عن يميني وأتيتُ الذي هو خير». (البخاري).
Don't be trapped by an oath — do what is better and pay the kaffārah.