`idx` is defined twice, could lead to errors