Re write in ocaml