merge Eran changes to permissions script