re-writing client code to work in it's own function. Code is now broken until I finish this.