Matrix iteration implemented.