refactored metadata retrieval