this algorithm looks good - but it brings up the resulting issue of making sure we take care of STATE properly.