working before refactor and sockets