fixed some bugs
quite satisfying thresholds implemented