Reverted derive_tag code to the original code