Changed threshold algorithm