refactoring client-side