Little refactoring for a better ruby way