Bug related to threshold calculation fixed