enhance code and generate loadMetadata