Used a more efficient way to get entities of type