refactored ch2 with a class, added rspec test