return index out of bound error instead of cryptic ocaml error