Changed the way of checking the keypairs