ruby related refactor