new version, with paritioning