Fixed bug in partition