threshold calculation