refactoring client into module pattern