added iteration logic