refactor and make room for websockets