Adding Prof. Minden's helper code.