Added q-value algorithm