Fix for-in loop error