merged Naor's changes