Defined getEntitiesWithComponent function