restructured things a bit so an error isn't generated while the browser replaces the location state