Implementation of second iteration.