add WritePermission

and fix some codes