reconfigured code for saving search state on router