refactor client side domain logic