Old version with thersholds