attemps at implementing exchange algorithm.