Bugfix in threshold logic