use FFI to get better performance