Fixed an error in permission check.