working model, but has segfault at end when close()?