refactoring + extend spectral partitioner