the idx function should be inline