Move initializeSocket function and remove excess events