web sockets,code cleaned