refactor for websockets usage