implemented client and standalone mode logic