added useMdRef toggle to retrieveEntity