modified to fit new style for FFI bindings