ruby refactoring