added custom metadata functionality to save function