Some ruby style refactoring