use getMetadataFor() method

hasMetadataFor() only works if the metadata has already been loaded