Move client code to client.js file