Fix #1 by implementing exchange algorithm from C.8