Fix: the loop should be along all indices