Fixed the bug when partition is not even.