Factorization method and singular Hamiltonians