general ruby best-practices refactor