Refactored and tested on irb