wrap cli client in function. clean up code.