entity stuff, make index code reusable
more entity stuff