Some Ruby style refactoring