Fix permission checking mechanism