Add partition function implementation