Fixed a bug when metadata is null.