refactor metadata lookup