code-reveiw and clean state.go