Added factory function to client