moved some code to socket urils