chore(socket) move var to top of func