refactored key_helper logic so that it's simpler