switching states via hooks