partition function done