´'Amr bin Shu'aib narrated from his father, from his grandfather, that the Messenger of Allah said:` "Whoever swears an oath, then sees something better than it, let him offer expiation for his oath, and do that which is better."
Related hadith on this topic