Refactored threshold functions.