Toandfro problem solved in scheme