added some code to work with metadata