how for loop works