removed duplication of code
refactoring iteration preparation