Fixed the for loop variable getting masked.