create a process_state function so as not to repeat code
codes from the inegi