Updating logic to check authorization.