This is probably better in F# than calling the imperative code directly