tweaked for custom entities