A method to protect quantum entanglement against certain kinds of phase and exchange errors