added certificate check