Fix clicking

Fix clicking by reversing inner loop order.