rewriting:  hopefully simpler and more efficient