split code into client.js, added sockets