refactored for clarity.  Following model suggested in Turnbulls Pro Puppet