handle either encoded or decoded indexes