improved performance of pie cluster creation and made it DRY