Refactor identity verification