Altered getEntities method