improved code for IndexExpr