Moving state endpoint into the main handler.