add io and modify for loop