Refactoring state.rb