more code refacoring for socket messages