Update ruby version.
Refactor to make the code simpler.