CPU optimized version of TVAL3 algorithm