stress detecting algorithm