implementing theq from SPTK