[ocaml] refactor codes