Handle any error when saving the tags
Refactored the metadata selection code