re-add pocock's code from 10/13, with enhancements/holes for future improvement