removed error handling in _process_state and required outside functions to do it