idx isn't defined here