first working prototyp with memory leaks