code refactor, removing invoke in client