Advance code for lille algoritmh. Not working version. Need to revise everything around sigma function