extract state fetching into method

* inline parse_state to avoid side-effects that were weird