A new method for determining excited states of quantum systems