Had for loops in wrong order.