tweaked using OCaml lambda interpreter