fixed error in permission check