fix order of index-loop variables