create websocket actor and refactor code