Refactor state.go