Fixed a bug in the Partiton algorithm