Might be worth keeping this, as it seems generally useful - ??