handle page refresh as well as navigate