[WIP] add support for secondary indexes

do you want me to move code below this line to a different function?