wrapping some of the scheme code by Oleg Kiselyov