more ruby refactoring