fixed #750 by separating out socket.js