Updating gems
Refactored code for readability/testability