Threshold implementation

- implementated threshold
- updated testcase
- strage segfault after some uses...