not working commit - segfault - but highly refactored