added logic for iterations