fixed the NPE reported by Don, and will do more testing