Refactoring to the adapter Pattern