Refactoring code by encapsulating Chain class inside Dollar namespace