correctly handle back/forward browser events