Move the navigation code into closure.