calculate average client side