fixing threshold operation