Fix the logic for checking what kind of key we have.