What does the substr exctract? Depending on that it could be moved to getEntititesForPage?