more rewrite to provide for testing