fix if metadata is undefined