moved socket disconnect function to correct area