refactory client side