I have been trying to modify a useful piece of code created by David Foster some time ago, However the one really useful addition to this code is proving hard to find in the ref