refactor and now working peer_cert check