i made a mistake. the partition function need to be improved