refactor.. segfault..