recursive alg in plain english. needs to be implemented