Refactor client funtions