indexBy thought through and almost completely tested