extracted the nav collapse method