Simplify some code in the socketservice