Adding bradybernard's existing code.