implementation of Li's CE method