refactored webSocketUpdate to decrease complexity