changed instantiation to deal with server and browser usage of client