I will discuss the O(n) loop model on a random surface and its connection with Conformal Loop Ensemples (CLE) and Liouville Quantum Gravity (LQG). Last year Borot, Bouttier and Duplantier determined the statistics of nesting of loops in both models and found that their large deviation functions are related by the Knizhnik-Polyakov-Zamolodchikov (KPZ) formula. In this talk I will give a probabilistic interpretation of this result by exhibiting a bijective relation between surfaces with loops and walks on the square lattice. The nesting statistics of the former are connected to the winding statistics of the latter.