A method of replacing a current key (KEY_1) in a security element co-operating with a terminal in a network operated by a network operator, said method comprising: A - When receiving an encrypted message from a distant platform, trying to decrypt said encrypted message by using said current key (KEY_1); B - If said current key (KEY_1) is not the key used by said distant platform to encrypt said message, selecting in a table stored in said secure element another key and try to decrypt said encrypted message by using said other key, said other key being: - a key called rescue key (RESCUE_KEYS) and being part of a window of said table, said window comprising n rescue keys, with n being >=0, or - a key called blocking key if n=0 or if said blocking key has a higher priority than said rescue keys (RESCUE_KEYS), said blocking key being stored outside said window, C - If n>0 and said rescue key permits to decrypt said encrypted message, replacing atomically said current key (KEY_1) by said rescue key and do not use said current key (KEY_1) anymore, said rescue key replacing said current key (KEY_1) and, otherwise, try to decrypt said encrypted message by using another rescue key of said window if such another rescue key exists, until all rescue keys have been selected and used for decrypting said encrypted message and, if none of said rescue keys permit to decrypt said encrypted message, select said blocking key, D - If said blocking key permits to decrypt said encrypted message, block the corresponding functionality of said security element. A - When receiving an encrypted message from a distant platform, trying to decrypt said encrypted message by using said current key (KEY_1); B - If said current key (KEY_1) is not the key used by said distant platform to encrypt said message, selecting in a table stored in said secure element another key and try to decrypt said encrypted message by using said other key, said other key being: - a key called rescue key (RESCUE_KEYS) and being part of a window of said table, said window comprising n rescue keys, with n being >=0, or - a key called blocking key if n=0 or if said blocking key has a higher priority than said rescue keys (RESCUE_KEYS), said blocking key being stored outside said window, - a key called rescue key (RESCUE_KEYS) and being part of a window of said table, said window comprising n rescue keys, with n being >=0, or - a key called blocking key if n=0 or if said blocking key has a higher priority than said rescue keys (RESCUE_KEYS), said blocking key being stored outside said window, C - If n>0 and said rescue key permits to decrypt said encrypted message, replacing atomically said current key (KEY_1) by said rescue key and do not use said current key (KEY_1) anymore, said rescue key replacing said current key (KEY_1) and, otherwise, try to decrypt said encrypted message by using another rescue key of said window if such another rescue key exists, until all rescue keys have been selected and used for decrypting said encrypted message and, if none of said rescue keys permit to decrypt said encrypted message, select said blocking key, D - If said blocking key permits to decrypt said encrypted message, block the corresponding functionality of said security element.