refactor 6 in ruby