client side code almost complete