ruby script refactoring continues...