Added check for metadata.title being undefined.