refactor so client is separate from library