Refactored random index resolution to remove demeter violation