Corrected variable in loop