simplified code of PrimaryDecomposition